<?php
class PrivilegeModel extends BaseModel{
    public static function isAvailable($req){
        $curRole=3;
        $module=strtolower($req->module);
        $controller=strtolower($req->controller);
        $action=strtolower($req->action);
        $roles=array(
            '1'=>'超级管理员',
            '2'=>'管理员',
            '3'=>'编辑'
        );
        $permission=array(
            '2'=>array(
                'index'=>array(
                    'privilege'=>array('users','groups'),
                ),
            ),
            '3'=>array(
                'index'=>array(
                    'privilege'=>array('users'),
                )
            ),
        );
        if($curRole==1){
            return true;
        }
        if (array_key_exists($curRole, $roles) && 
            array_key_exists($controller, $permission[$curRole][$module]) &&
            in_array($action, $permission[$curRole][$module][$controller])) {
            return true;
        }else{
            return false;
        }
    }

}